import { ref } from "vue"
import { defineStore } from "pinia"

export const useUserStore = defineStore("user", () => {
  const isFirst = ref(true)
  const firstBlogs = ref([])
  const token = ref("")
  const userinfo = ref(null)
  const updateUserinfo = (rData) => {
    userinfo.value = rData
  }
  const updateToken = (rData) => {
    if (rData === undefined) {
      token.value = ""
    } else {
      token.value = rData.tokens.access
    }
  }

  const frinedLinks = ref([
    {
      id: 1,
      type: "link",
      author: "诗意栖居",
      context: "文学爱好者的精神家园",
      icon: "fas fa-feather",
    },
    {
      id: 2,
      type: "link",
      author: "墨色艺廊",
      context: "艺术与设计的交流平台",
      icon: "fas fa-paint-brush",
    },
    {
      id: 3,
      type: "link",
      author: "音律空间",
      context: "独立音乐人的创作天地",
      icon: "fas fa-music",
    },
    {
      id: 4,
      type: "link",
      author: "光影世界",
      context: "摄影与视觉艺术的展示平台",
      icon: "fas fa-camera",
    },
    {
      id: 5,
      type: "link",
      author: "书海泛舟",
      context: "文学评论与书籍推荐",
      icon: "fas fa-book",
    },
    {
      id: 6,
      type: "link",
      author: "星夜沉思",
      context: "哲学与思考的深夜角落",
      icon: "fas fa-moon",
    },
  ])

  return { isFirst, firstBlogs, token, userinfo, frinedLinks, updateToken, updateUserinfo }
})
